// @author: caoshi
// @date: 2021-06-06 20:50
package initialize

import (
	"demo08_paramsbind/src/router"
	"github.com/gin-contrib/sessions"
	"github.com/gin-contrib/sessions/cookie"
	"github.com/gin-gonic/gin"
)

// 初始项目所有路由
func Routers() *gin.Engine {
	Router := gin.Default()
	// 1. 初始化session
	store := cookie.NewStore([]byte("secret11111"))

	// 1. 设置 一个总的 Router Group, 以便统一添加路由组前缀
	AllGroups := Router.Group("")
	// 2. 使用中间件 session
	AllGroups.Use(sessions.Sessions("mysession", store))
	{
		router.InitBaseRouter(AllGroups)
		router.InitBlogsRouter(AllGroups)
		router.InitUserRouter(AllGroups)
	}
	return Router
}
